var id = sessionStorage.getItem("productId");

if (id) {
    axios.get(`http://localhost:9000/goods/item/${id}`)
        .then(({data}) => {
            if (data.code === 1) {
                const itemInfo = data.info;
                // 渲染商品详情
                document.querySelector(".middleimg").src = itemInfo.img_big_logo;
                document.querySelector(".title").textContent = itemInfo.title;
                document.querySelector(".old").textContent = itemInfo.price;
                document.querySelector(".discount").textContent = itemInfo.sale_type;
                document.querySelector(".curprice").textContent = itemInfo.current_price;
                document.querySelector(".desc").innerHTML = itemInfo.goods_introduce;
            } else if (data.code === 0) {
                alert(data.msg);
            }
        })
        .catch(error => {
            console.error('Error:', error);
        });
} else {
    console.error('id不存在');
}